﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Meqs.Entity;
using System.Collections.Generic;

public partial class School_Manage_InputScore_Left : System.Web.UI.Page
{
    /// <summary>
    /// 考试号
    /// </summary>
    protected int examid = 0;
    /// <summary>
    /// 是否为统考 -1错误，1是，0不是
    /// </summary>
    protected int eexam = -1;
    /// <summary>
    /// 班级分科
    /// </summary>
    protected int classType = -1;
    /// <summary>
    /// 班级列表
    /// </summary>
    protected IList<ClsInfo> clsinfo = null;
    /// <summary>
    /// 考试年级
    /// </summary>
    protected int Grade = 0;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            string iseexam = SchoolCookie.ExamType.ToString();
            string id = SchoolCookie.ExamID.ToString();
            //string iseexam = "1";
            //string id = "1";
            int temp = 0;
            if (int.TryParse(id, out temp))
            {
                examid = temp;
            }

            temp = -1;
            if (int.TryParse(iseexam, out temp))
            {
                eexam = temp;
            }
            if (eexam != -1 && examid != 0)
            {
                SetClsinfo(eexam, examid);
            }
        }
    }
    private void SetClsinfo(int em,int id)
    {
        int grade = -1;
        int type = -1;
        ///是统考
        if (em == 1)
        {
            ExamsEducation ee = Container<Meqs.Logic.Interface.IExamsEducationLogic>.Instance.FindById(id);
            grade = ee.Grade;
            type = ee.ClassType;
        }
        else
        {
            ///不是统考
            Hashtable ht = new Hashtable();
            ht.Add("SchoolMark", CommonScore.GetSchoolMark);
            ht.Add("RID", id);
            IList<ExamsSchool> es = Container<Meqs.Logic.Interface.IExamsSchoolLogic>.Instance.FindAll(ht);
            if (es.Count > 0)
            {
                grade = es[0].Grade;
                type = es[0].ClassType;
            }
        }
        
        if (grade != -1 && type != -1)
        {
            Grade = grade;
            Hashtable ht = new Hashtable();
            ht.Add("Grade", grade);
            ht.Add("DivSub", type);
            ht.Add("IsEffect", 1);
            ht.Add("SchoolMark", CommonScore.GetSchoolMark);
            classType = type;
            clsinfo = Container<Meqs.Logic.Interface.IClsInfoLogic>.Instance.FindAll(ht);
        }
    }
    private void OutPage()
    {
        Response.Write("<script>window.opener=null;window.close();</script>");
        Response.End();
    }
}
